/**
* The Footbar global namespace
* Usage  
* @class Footbar
* @static
*/
if (typeof Footbar == "undefined") {
 	Footbar = {};
}

Footbar.FireTag=function(oName){
	var name=oName;
	var props={
				startDelim:"{",
				endDelim:"}"
			   };
	var template="No Template Defined";
	var map=[];

	/**
	*  Function Escapes regex Special Characters
	*/
	var escapeDelimeter=function(delim){
		var xList=["(","[","{","\\","^","$","|",")","?","*","+","."];
		for(var i=0;i<xList.length;i++){
			if(xList[i]==delim)return ("\\"+delim);
		}
		return delim;
	}
	
	//Public Methods
	return{
		properties:function(o){
			
		},
		setTemplate : function(template){
			this.template=template;
		},
		addVariable:function(key,value){
			key=escapeDelimeter(props.startDelim)+key+escapeDelimeter(props.endDelim);
			map.push({key:key,value:value});
		},
		run:function(){
			while((data=map.pop())!=null){
				var rx=new RegExp(data.key, "g");
				this.template=this.template.replace(rx,data.value);
			}
			return this.template;
		},
        reset:function(){
            map=[];
        }
    };
};
